Skip to content

Conversation

@sunhaosheng
Copy link
Contributor

@sunhaosheng sunhaosheng commented Dec 31, 2025

  • Add shrink logic in sys_brk: when the new break is lower than the current top, unmap the corresponding pages
  • Only reclaim pages above the initially mapped heap region (USER_HEAP_SIZE) to avoid breaking the ELF-loaded heap

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for shrinking the program break (brk) by implementing logic to unmap pages when the heap shrinks. The implementation mirrors the existing expansion logic and ensures that only pages beyond the initially ELF-loaded heap region can be reclaimed.

Key changes:

  • Added shrink logic that unmaps pages when the new break point is below the current heap top
  • Protection of the initially mapped heap region (USER_HEAP_SIZE) from being unmapped

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AsakuraMizu AsakuraMizu changed the title mm: support shrinking brk fix: brk shrink Jan 12, 2026
@AsakuraMizu AsakuraMizu merged commit 0018597 into Starry-OS:main Jan 12, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants